//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for ApplicationDiscoveryService
public struct ApplicationDiscoveryServiceErrorType: AWSErrorType {
    enum Code: String {
        case authorizationErrorException = "AuthorizationErrorException"
        case conflictErrorException = "ConflictErrorException"
        case homeRegionNotSetException = "HomeRegionNotSetException"
        case invalidParameterException = "InvalidParameterException"
        case invalidParameterValueException = "InvalidParameterValueException"
        case operationNotPermittedException = "OperationNotPermittedException"
        case resourceInUseException = "ResourceInUseException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serverInternalErrorException = "ServerInternalErrorException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize ApplicationDiscoveryService
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The AWS user account does not have permission to perform the action. Check the IAM policy associated with this account.
    public static var authorizationErrorException: Self { .init(.authorizationErrorException) }
    public static var conflictErrorException: Self { .init(.conflictErrorException) }
    /// The home region is not set. Set the home region to continue.
    public static var homeRegionNotSetException: Self { .init(.homeRegionNotSetException) }
    /// One or more parameters are not valid. Verify the parameters and try again.
    public static var invalidParameterException: Self { .init(.invalidParameterException) }
    /// The value of one or more parameters are either invalid or out of range. Verify the parameter values and try again.
    public static var invalidParameterValueException: Self { .init(.invalidParameterValueException) }
    /// This operation is not permitted.
    public static var operationNotPermittedException: Self { .init(.operationNotPermittedException) }
    /// This issue occurs when the same clientRequestToken is used with the StartImportTask action, but with different parameters. For example, you use the same request token but have two different import URLs, you can encounter this issue. If the import tasks are meant to be different, use a different clientRequestToken, and try again.
    public static var resourceInUseException: Self { .init(.resourceInUseException) }
    /// The specified configuration ID was not located. Verify the configuration ID and try again.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The server experienced an internal error. Try again.
    public static var serverInternalErrorException: Self { .init(.serverInternalErrorException) }
}

extension ApplicationDiscoveryServiceErrorType: Equatable {
    public static func == (lhs: ApplicationDiscoveryServiceErrorType, rhs: ApplicationDiscoveryServiceErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension ApplicationDiscoveryServiceErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
